#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Person{
        string m_name;
        int m_age;
        vector<char> m_id;
    public:
        Person(const string& name,int age):m_name{name},m_age{age},m_id{'9','5','2','7'}/*(12)成员变量初始化*/{};
        Person(const string& name,int age,vector<char>& id):m_name{name},m_age{age},m_id{id}{};//m_id(id)也可以
        Person()=default;
        Person(std::initializer_list<Person>){}

        void info() const {
            std::cout<<"Name = "<<m_name<<" Age = "<<m_age<<"\n";
        }
};
Person make_person(const string&name,int age){
    return {name,age};//(8)
}
void show_person(const Person&p){
    p.info();
}
int main(){
    Person p = Person("john",18);
    Person p1;// Person() = default
    Person p2 = {"Julia",19}; // Person(std::initializer_list<Person>)(6)
    p.info();
    p2.info();
    Person {"limei",18};//C++17之后不在生成临时变量(2)
    auto p3 = make_person("hell",20);
    p3.info();
    show_person(Person{"lime",20});//(7)
    auto p4 = new Person{"john1",12};//new 创建一个Person (3)
    p4->info();
    delete p4;
    Person p5{"John2",12};// (1)
    p5.info();
    p1 = {"John4",14};//(10)
    p1.info();
    const int (&ar)[2] = {1, 2};//绑定左值到临时数组
    std::cout<<"ar[0] "<<ar[0]<<" ar[1] "<<ar[1]<<"\n";

}
